A heterogeneous computer system comprises two or more processors. Processors in the system may implement architectures that are different from each other. In particular, each of the processors may have instruction set architectures (ISAs) that are different. In the heterogeneous computer system, a single program or application may be executed by one or more processors of the heterogeneous computer system.
However, a function that is instantiated once within the program may be not be executable by different processors. That is, a function that is instantiated within the program may be compatible with one ISA of a first processor, but is not compatible with another ISA of a second processor. As such, depending on which processor is executing parts of the program at a particular time, the function may or may not be executable.
Some programming languages expose the relation between functions and their instantiations to programmers. Many languages treat functions as objects that can be stored, retrieved and subsequently called. Those languages which further guarantee constant algorithmic time for these operations have standardized in norm or in practice that programs may assert the existence of a unique bidirectional relation between function and function instances. Heterogeneous systems break these assumptions by creating a non-unique relation between functions and function instances.
In particular, the International Organization for Standardization (ISO) C and C++ languages mandate that each function (that is one definition rule (ODR) based, see ISO-9899 and ISO-14882) have a unique instantiation, with a unique address for accessing. The programming languages further state that the address of the function may be taken (e.g., with the “&” operator) and stored in a variable of a suitable function pointer type. As such, the function associated with the function pointer variable may then be stored in memory for later access. In the case of a heterogeneous system, the function that is called within a program must be executable by any or all of the processors capable of accessing the pointer.
A problem is encountered when an incompatible processor is executing the function. Typically, the function that is stored in the address taken within the function pointer variable is compiled for a particular processor. Though the source code may be written in a manner that is compatible with all the processors, at the machine or assembly level, the function stored may only be compatible with one ISA of a corresponding processor. As such, when the function pointer is dereferenced (e.g., using the “*” operator), the function whose address was stored within the function pointer variable is called. This behavior is mandated, even if different processors execute the “&” and “*” operators. However, if the function is not compiled for the processor calling the function, then that processor will not be able to execute the function. As a result, the program will fail.
It is desirous to have a heterogeneous computer system be able to execute a function across all ISAs of processors included within the system.